// DiagnosisController.java
package com.projects.modular.realty.controller;

import com.projects.modular.realty.model.params.DiagnosisParam;
import com.projects.modular.realty.model.vo.DiagnosisVo;
import com.projects.modular.realty.service.DiagnosisService;
import com.projects.config.web.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 疼痛记录控制器
 *
 * @author 曾大顺
 * @since 2025-02-11
 */
@RestController
@RequestMapping("/api/diagnosis")
@Api(tags = "疼痛记录管理")
public class DiagnosisController {

    @Resource
    private DiagnosisService diagnosisService;

    /**
     * 新增疼痛记录
     *
     * @author 曾大顺
     * @since 2025-02-11
     */
    @ApiOperation("新增疼痛记录")
    @PostMapping("/add")
    public ResponseData add(@RequestBody DiagnosisParam diagnosisParam) {
        this.diagnosisService.add(diagnosisParam);
        return ResponseData.success("添加成功");
    }

    /**
     * 编辑疼痛记录
     *
     * @author 曾大顺
     * @since 2025-02-11
     */
    @ApiOperation("编辑疼痛记录")
    @PostMapping("/edit")
    public ResponseData edit(@RequestBody DiagnosisParam diagnosisParam) {
        this.diagnosisService.update(diagnosisParam);
        return ResponseData.success("修改成功");
    }

    /**
     * 删除疼痛记录
     *
     * @author 曾大顺
     * @since 2025-02-11
     */
    @ApiOperation("删除疼痛记录")
    @GetMapping("/delete")
    public ResponseData delete(@RequestParam String diagnosisId) {
        this.diagnosisService.deleteById(diagnosisId);
        return ResponseData.success("删除成功");
    }

    /**
     * 查看详情
     *
     * @author 曾大顺
     * @since 2025-02-11
     */
    @ApiOperation("查看疼痛记录详情")
    @GetMapping("/detail")
    public ResponseData detail(@RequestParam String diagnosisId) {
        DiagnosisParam detail = this.diagnosisService.getDetailById(diagnosisId);
        return ResponseData.success(detail);
    }


    /**
     * 根据孩子ID查询所有疼痛记录
     *
     * @author 曾大顺
     * @since 2025-02-11
     */
    @ApiOperation("根据孩子ID查询所有疼痛记录")
    @GetMapping("/list")
    public ResponseData list(@RequestParam String childId) {
        List<DiagnosisParam> diagnosisList = this.diagnosisService.getByChildId(childId);
        return ResponseData.success(diagnosisList);
    }


    /**
     * 获取疼痛记录列表
     * @author 曾大顺
     * @since 2025-02-11
     */
    @ApiOperation("获取疼痛记录列表")
    @PostMapping("/getDiagnosisList")
    public ResponseData getDiagnosisList(@RequestBody DiagnosisVo diagnosisVo) {
        List<DiagnosisParam> diagnosisList = this.diagnosisService.getDiagnosisList(diagnosisVo);
        return ResponseData.success(diagnosisList);
    }
}
